package com.nand.module.user.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.nand.library.base.base.BaseActivity;
import com.nand.library.base.utils.SharedPreferencesUtils;
import com.nand.module.user.R;
import com.nand.module.user.adapter.UserInfoListAdapter;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

@Route(path = "/user/main")
public class UMainActivity extends BaseActivity {


    @Override
    protected int initLayout() {
        return R.layout.activity_umain;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void initView() {
        RecyclerView recyclerView = findViewById(R.id.user_rv);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(layoutManager);
        UserInfoListAdapter adapter = new UserInfoListAdapter(this);
        recyclerView.setAdapter(adapter);

        adapter.setOnItemClickListener(new UserInfoListAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                switch (position) {
                    case 0:
                        Intent intent = new Intent(UMainActivity.this, UserInfoActivity.class);
                        UMainActivity.this.startActivity(intent);
                        break;
                    case 5:
                        SharedPreferencesUtils.clear(UMainActivity.this, "userInfo");
                        Intent intent1 = new Intent(UMainActivity.this, LoginActivity.class);
                        UMainActivity.this.startActivity(intent1);
                        break;
                    default:
                        showToast("功能暂未开通！");
                        break;
                }
            }
        });
        adapter.setOnClickListener(new UserInfoListAdapter.setOnClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                switch (position) {
                    case 0:
                        finish();
                        break;
                    case 1:
//                        Intent intent1 = new Intent(UMainActivity.this, LoginActivity.class);
//                        UMainActivity.this.startActivity(intent1);
                        break;
                    default:
                        showToast("功能暂未开通！");
                        break;
                }
            }
        });
    }

    @Override
    protected void initData() {
        setStatusBar(R.color.transparent);
    }
}
